import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.0

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Bigfile copy")

    property int spaceSize: 30
    property int btnWidth: 100
    property int btnHeight: 50
    property string totalByteStr: "Source total bytes:  "
    property string writtenByteStr: "Target written bytes:  "
    property string copyPercentStr: "Copy percent:  "

    Column {
        id: column
        spacing: spaceSize
        anchors.centerIn: parent

        Row {
            id: row
            spacing: spaceSize

            Button {
                id: btnCopy
                text: "Copy";
                width: btnWidth
                height: btnHeight
                onClicked: {
                    var source = "/home/xll/Desktop/11/1.mp4";
                    var target = "/home/xll/Desktop/11/2.mp4";
                    FileSystem.startCopy(source, target);
                }
            }

            Button {
                id: btnCancel
                text: "Cancel";
                width: btnWidth
                height: btnHeight
                onClicked: {
                    FileSystem.cancelCopy();
                }
            }
        }

        Label {
            id: labSourceByte
        }

        Label {
            id: labWrittenByte
        }

        Label {
            id: labPercent
        }

        Connections {
            target: FileSystem
            onProgress: {
                labSourceByte.text = totalByteStr + totalbyte;
                labWrittenByte.text = writtenByteStr + writtenbyte;
                labPercent.text = copyPercentStr + percent;
            }
        }
    }
}
